{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9d077948",
   "metadata": {},
   "source": [
    "## Building pandas Series and DataFrames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3ac7fa14",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from IPython.display import display\n",
    "from openbb import obb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "353937e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "obb.user.preferences.output_type = \"dataframe\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f089ad68",
   "metadata": {},
   "source": [
    "Generates a date range with second frequency starting from 2016-01-01 for 100 periods and displays it"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6adbf73d",
   "metadata": {},
   "outputs": [],
   "source": [
    "seconds = pd.date_range(\"2016-01-01\", periods=100, freq=\"s\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "502d6063",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2016-01-01 00:00:00', '2016-01-01 00:00:01',\n",
       "               '2016-01-01 00:00:02', '2016-01-01 00:00:03',\n",
       "               '2016-01-01 00:00:04', '2016-01-01 00:00:05',\n",
       "               '2016-01-01 00:00:06', '2016-01-01 00:00:07',\n",
       "               '2016-01-01 00:00:08', '2016-01-01 00:00:09',\n",
       "               '2016-01-01 00:00:10', '2016-01-01 00:00:11',\n",
       "               '2016-01-01 00:00:12', '2016-01-01 00:00:13',\n",
       "               '2016-01-01 00:00:14', '2016-01-01 00:00:15',\n",
       "               '2016-01-01 00:00:16', '2016-01-01 00:00:17',\n",
       "               '2016-01-01 00:00:18', '2016-01-01 00:00:19',\n",
       "               '2016-01-01 00:00:20', '2016-01-01 00:00:21',\n",
       "               '2016-01-01 00:00:22', '2016-01-01 00:00:23',\n",
       "               '2016-01-01 00:00:24', '2016-01-01 00:00:25',\n",
       "               '2016-01-01 00:00:26', '2016-01-01 00:00:27',\n",
       "               '2016-01-01 00:00:28', '2016-01-01 00:00:29',\n",
       "               '2016-01-01 00:00:30', '2016-01-01 00:00:31',\n",
       "               '2016-01-01 00:00:32', '2016-01-01 00:00:33',\n",
       "               '2016-01-01 00:00:34', '2016-01-01 00:00:35',\n",
       "               '2016-01-01 00:00:36', '2016-01-01 00:00:37',\n",
       "               '2016-01-01 00:00:38', '2016-01-01 00:00:39',\n",
       "               '2016-01-01 00:00:40', '2016-01-01 00:00:41',\n",
       "               '2016-01-01 00:00:42', '2016-01-01 00:00:43',\n",
       "               '2016-01-01 00:00:44', '2016-01-01 00:00:45',\n",
       "               '2016-01-01 00:00:46', '2016-01-01 00:00:47',\n",
       "               '2016-01-01 00:00:48', '2016-01-01 00:00:49',\n",
       "               '2016-01-01 00:00:50', '2016-01-01 00:00:51',\n",
       "               '2016-01-01 00:00:52', '2016-01-01 00:00:53',\n",
       "               '2016-01-01 00:00:54', '2016-01-01 00:00:55',\n",
       "               '2016-01-01 00:00:56', '2016-01-01 00:00:57',\n",
       "               '2016-01-01 00:00:58', '2016-01-01 00:00:59',\n",
       "               '2016-01-01 00:01:00', '2016-01-01 00:01:01',\n",
       "               '2016-01-01 00:01:02', '2016-01-01 00:01:03',\n",
       "               '2016-01-01 00:01:04', '2016-01-01 00:01:05',\n",
       "               '2016-01-01 00:01:06', '2016-01-01 00:01:07',\n",
       "               '2016-01-01 00:01:08', '2016-01-01 00:01:09',\n",
       "               '2016-01-01 00:01:10', '2016-01-01 00:01:11',\n",
       "               '2016-01-01 00:01:12', '2016-01-01 00:01:13',\n",
       "               '2016-01-01 00:01:14', '2016-01-01 00:01:15',\n",
       "               '2016-01-01 00:01:16', '2016-01-01 00:01:17',\n",
       "               '2016-01-01 00:01:18', '2016-01-01 00:01:19',\n",
       "               '2016-01-01 00:01:20', '2016-01-01 00:01:21',\n",
       "               '2016-01-01 00:01:22', '2016-01-01 00:01:23',\n",
       "               '2016-01-01 00:01:24', '2016-01-01 00:01:25',\n",
       "               '2016-01-01 00:01:26', '2016-01-01 00:01:27',\n",
       "               '2016-01-01 00:01:28', '2016-01-01 00:01:29',\n",
       "               '2016-01-01 00:01:30', '2016-01-01 00:01:31',\n",
       "               '2016-01-01 00:01:32', '2016-01-01 00:01:33',\n",
       "               '2016-01-01 00:01:34', '2016-01-01 00:01:35',\n",
       "               '2016-01-01 00:01:36', '2016-01-01 00:01:37',\n",
       "               '2016-01-01 00:01:38', '2016-01-01 00:01:39'],\n",
       "              dtype='datetime64[ns]', freq='s')"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(seconds)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa2c9ff3",
   "metadata": {
    "lines_to_next_cell": 2
   },
   "source": [
    "Defines a function 'rnd' that returns an array of 100 random numbers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "4826f994",
   "metadata": {},
   "outputs": [],
   "source": [
    "def rnd():\n",
    "    return np.random.randn(\n",
    "        100,\n",
    "    )"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6c99e8ca",
   "metadata": {},
   "source": [
    "Creates three pandas Series with random data and the previously generated seconds as index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "060ec773",
   "metadata": {},
   "outputs": [],
   "source": [
    "s_1 = pd.Series(rnd(), index=seconds)\n",
    "s_2 = pd.Series(rnd(), index=seconds)\n",
    "s_3 = pd.Series(rnd(), index=seconds)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a185c5e",
   "metadata": {},
   "source": [
    "Creates a DataFrame 'df' from the three Series and displays it"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d3f7982e",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame({\"a\": s_1, \"b\": s_2, \"c\": s_3})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2b3e4871",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>a</th>\n",
       "      <th>b</th>\n",
       "      <th>c</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:00:00</th>\n",
       "      <td>0.831923</td>\n",
       "      <td>-0.939787</td>\n",
       "      <td>-0.616651</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:00:01</th>\n",
       "      <td>-0.603660</td>\n",
       "      <td>-1.242581</td>\n",
       "      <td>-0.940818</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:00:02</th>\n",
       "      <td>-0.784384</td>\n",
       "      <td>2.424799</td>\n",
       "      <td>0.683260</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:00:03</th>\n",
       "      <td>0.208618</td>\n",
       "      <td>0.014171</td>\n",
       "      <td>-1.715118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:00:04</th>\n",
       "      <td>0.013850</td>\n",
       "      <td>-0.562456</td>\n",
       "      <td>-0.673387</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:01:35</th>\n",
       "      <td>-0.741422</td>\n",
       "      <td>1.003279</td>\n",
       "      <td>-0.084374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:01:36</th>\n",
       "      <td>-1.238774</td>\n",
       "      <td>-1.250313</td>\n",
       "      <td>0.847776</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:01:37</th>\n",
       "      <td>-0.003752</td>\n",
       "      <td>-1.524192</td>\n",
       "      <td>0.397260</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:01:38</th>\n",
       "      <td>-0.798505</td>\n",
       "      <td>0.681638</td>\n",
       "      <td>0.412192</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01 00:01:39</th>\n",
       "      <td>0.195336</td>\n",
       "      <td>0.961961</td>\n",
       "      <td>-0.710493</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                            a         b         c\n",
       "2016-01-01 00:00:00  0.831923 -0.939787 -0.616651\n",
       "2016-01-01 00:00:01 -0.603660 -1.242581 -0.940818\n",
       "2016-01-01 00:00:02 -0.784384  2.424799  0.683260\n",
       "2016-01-01 00:00:03  0.208618  0.014171 -1.715118\n",
       "2016-01-01 00:00:04  0.013850 -0.562456 -0.673387\n",
       "...                       ...       ...       ...\n",
       "2016-01-01 00:01:35 -0.741422  1.003279 -0.084374\n",
       "2016-01-01 00:01:36 -1.238774 -1.250313  0.847776\n",
       "2016-01-01 00:01:37 -0.003752 -1.524192  0.397260\n",
       "2016-01-01 00:01:38 -0.798505  0.681638  0.412192\n",
       "2016-01-01 00:01:39  0.195336  0.961961 -0.710493\n",
       "\n",
       "[100 rows x 3 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "71a3affa",
   "metadata": {},
   "source": [
    "Creates a list of tuples with date and symbol"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "50a4d053",
   "metadata": {},
   "outputs": [],
   "source": [
    "tuples = [\n",
    "    (pd.Timestamp(\"2023-07-10\"), \"WMT\"),\n",
    "    (pd.Timestamp(\"2023-07-10\"), \"JPM\"),\n",
    "    (pd.Timestamp(\"2023-07-10\"), \"TGT\"),\n",
    "    (pd.Timestamp(\"2023-07-11\"), \"WMT\"),\n",
    "    (pd.Timestamp(\"2023-07-11\"), \"JPM\"),\n",
    "    (pd.Timestamp(\"2023-07-11\"), \"TGT\"),\n",
    "]\n",
    "midx = pd.MultiIndex.from_tuples(tuples, names=(\"date\", \"symbol\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a3b77bac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(Timestamp('2023-07-10 00:00:00'), 'WMT'),\n",
       " (Timestamp('2023-07-10 00:00:00'), 'JPM'),\n",
       " (Timestamp('2023-07-10 00:00:00'), 'TGT'),\n",
       " (Timestamp('2023-07-11 00:00:00'), 'WMT'),\n",
       " (Timestamp('2023-07-11 00:00:00'), 'JPM'),\n",
       " (Timestamp('2023-07-11 00:00:00'), 'TGT')]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(tuples)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0aa26baa",
   "metadata": {},
   "source": [
    "Creates a MultiIndex from the list of tuples and assigns it to the index of a new DataFrame 'df'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6171095a",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(\n",
    "    {\n",
    "        \"close\": [158.11, 144.64, 132.55, 158.20, 146.61, 134.86],\n",
    "        \"factor_1\": [0.31, 0.24, 0.67, 0.29, 0.23, 0.71],\n",
    "    },\n",
    "    index=midx,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "759e98a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>factor_1</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>symbol</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">2023-07-10</th>\n",
       "      <th>WMT</th>\n",
       "      <td>158.11</td>\n",
       "      <td>0.31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>JPM</th>\n",
       "      <td>144.64</td>\n",
       "      <td>0.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TGT</th>\n",
       "      <td>132.55</td>\n",
       "      <td>0.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">2023-07-11</th>\n",
       "      <th>WMT</th>\n",
       "      <td>158.20</td>\n",
       "      <td>0.29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>JPM</th>\n",
       "      <td>146.61</td>\n",
       "      <td>0.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TGT</th>\n",
       "      <td>134.86</td>\n",
       "      <td>0.71</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    close  factor_1\n",
       "date       symbol                  \n",
       "2023-07-10 WMT     158.11      0.31\n",
       "           JPM     144.64      0.24\n",
       "           TGT     132.55      0.67\n",
       "2023-07-11 WMT     158.20      0.29\n",
       "           JPM     146.61      0.23\n",
       "           TGT     134.86      0.71"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f114d6e",
   "metadata": {},
   "source": [
    "Fetches options chains for the symbol \"SPY\" using the \"cboe\" provider and stores it in 'chains'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "9387d410",
   "metadata": {},
   "outputs": [],
   "source": [
    "chains = obb.derivatives.options.chains(\"SPY\", provider=\"cboe\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fc7d2aa5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>contract_symbol</th>\n",
       "      <th>expiration</th>\n",
       "      <th>strike</th>\n",
       "      <th>option_type</th>\n",
       "      <th>open_interest</th>\n",
       "      <th>volume</th>\n",
       "      <th>theoretical_price</th>\n",
       "      <th>last_trade_price</th>\n",
       "      <th>tick</th>\n",
       "      <th>bid</th>\n",
       "      <th>...</th>\n",
       "      <th>change</th>\n",
       "      <th>change_percent</th>\n",
       "      <th>implied_volatility</th>\n",
       "      <th>delta</th>\n",
       "      <th>gamma</th>\n",
       "      <th>theta</th>\n",
       "      <th>vega</th>\n",
       "      <th>rho</th>\n",
       "      <th>last_trade_timestamp</th>\n",
       "      <th>dte</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>SPY240614C00350000</td>\n",
       "      <td>2024-06-14</td>\n",
       "      <td>350.0</td>\n",
       "      <td>call</td>\n",
       "      <td>149</td>\n",
       "      <td>147</td>\n",
       "      <td>192.4600</td>\n",
       "      <td>191.34</td>\n",
       "      <td>down</td>\n",
       "      <td>191.83</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.495</td>\n",
       "      <td>-0.0078</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>2024-06-14 14:16:52</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>SPY240614P00350000</td>\n",
       "      <td>2024-06-14</td>\n",
       "      <td>350.0</td>\n",
       "      <td>put</td>\n",
       "      <td>1061</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.01</td>\n",
       "      <td>no_change</td>\n",
       "      <td>0.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.005</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>2024-06-14 09:32:54</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>SPY240614C00355000</td>\n",
       "      <td>2024-06-14</td>\n",
       "      <td>355.0</td>\n",
       "      <td>call</td>\n",
       "      <td>0</td>\n",
       "      <td>64</td>\n",
       "      <td>187.4600</td>\n",
       "      <td>187.24</td>\n",
       "      <td>down</td>\n",
       "      <td>186.85</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.615</td>\n",
       "      <td>-0.0033</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>2024-06-14 15:57:53</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>SPY240614P00355000</td>\n",
       "      <td>2024-06-14</td>\n",
       "      <td>355.0</td>\n",
       "      <td>put</td>\n",
       "      <td>466</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.01</td>\n",
       "      <td>down</td>\n",
       "      <td>0.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>2024-06-05 13:19:59</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SPY240614C00360000</td>\n",
       "      <td>2024-06-14</td>\n",
       "      <td>360.0</td>\n",
       "      <td>call</td>\n",
       "      <td>32</td>\n",
       "      <td>6</td>\n",
       "      <td>182.4600</td>\n",
       "      <td>181.25</td>\n",
       "      <td>down</td>\n",
       "      <td>181.85</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.605</td>\n",
       "      <td>-0.0088</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>2024-06-14 14:17:16</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9159</th>\n",
       "      <td>SPY261218P00800000</td>\n",
       "      <td>2026-12-18</td>\n",
       "      <td>800.0</td>\n",
       "      <td>put</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>258.5150</td>\n",
       "      <td>266.86</td>\n",
       "      <td>up</td>\n",
       "      <td>256.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.9998</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0153</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1534</td>\n",
       "      <td>2024-06-11 09:41:34</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9160</th>\n",
       "      <td>SPY261218C00805000</td>\n",
       "      <td>2026-12-18</td>\n",
       "      <td>805.0</td>\n",
       "      <td>call</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3.1599</td>\n",
       "      <td>0.00</td>\n",
       "      <td>no_change</td>\n",
       "      <td>0.50</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.1207</td>\n",
       "      <td>0.0760</td>\n",
       "      <td>0.0014</td>\n",
       "      <td>-0.0074</td>\n",
       "      <td>1.2912</td>\n",
       "      <td>0.9325</td>\n",
       "      <td>NaT</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9161</th>\n",
       "      <td>SPY261218P00805000</td>\n",
       "      <td>2026-12-18</td>\n",
       "      <td>805.0</td>\n",
       "      <td>put</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>263.5095</td>\n",
       "      <td>0.00</td>\n",
       "      <td>no_change</td>\n",
       "      <td>261.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.9998</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0149</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1546</td>\n",
       "      <td>NaT</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9162</th>\n",
       "      <td>SPY261218C00810000</td>\n",
       "      <td>2026-12-18</td>\n",
       "      <td>810.0</td>\n",
       "      <td>call</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2.9770</td>\n",
       "      <td>2.56</td>\n",
       "      <td>down</td>\n",
       "      <td>0.25</td>\n",
       "      <td>...</td>\n",
       "      <td>2.560</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.1200</td>\n",
       "      <td>0.0722</td>\n",
       "      <td>0.0013</td>\n",
       "      <td>-0.0072</td>\n",
       "      <td>1.2440</td>\n",
       "      <td>0.8859</td>\n",
       "      <td>2024-06-14 12:22:40</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9163</th>\n",
       "      <td>SPY261218P00810000</td>\n",
       "      <td>2026-12-18</td>\n",
       "      <td>810.0</td>\n",
       "      <td>put</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>268.5041</td>\n",
       "      <td>0.00</td>\n",
       "      <td>no_change</td>\n",
       "      <td>266.00</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.9998</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0146</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1554</td>\n",
       "      <td>NaT</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9164 rows × 27 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         contract_symbol  expiration  strike option_type  open_interest  \\\n",
       "0     SPY240614C00350000  2024-06-14   350.0        call            149   \n",
       "1     SPY240614P00350000  2024-06-14   350.0         put           1061   \n",
       "2     SPY240614C00355000  2024-06-14   355.0        call              0   \n",
       "3     SPY240614P00355000  2024-06-14   355.0         put            466   \n",
       "4     SPY240614C00360000  2024-06-14   360.0        call             32   \n",
       "...                  ...         ...     ...         ...            ...   \n",
       "9159  SPY261218P00800000  2026-12-18   800.0         put              1   \n",
       "9160  SPY261218C00805000  2026-12-18   805.0        call              0   \n",
       "9161  SPY261218P00805000  2026-12-18   805.0         put              0   \n",
       "9162  SPY261218C00810000  2026-12-18   810.0        call              0   \n",
       "9163  SPY261218P00810000  2026-12-18   810.0         put              0   \n",
       "\n",
       "      volume  theoretical_price  last_trade_price       tick     bid  ...  \\\n",
       "0        147           192.4600            191.34       down  191.83  ...   \n",
       "1          1             0.0000              0.01  no_change    0.00  ...   \n",
       "2         64           187.4600            187.24       down  186.85  ...   \n",
       "3          0             0.0000              0.01       down    0.00  ...   \n",
       "4          6           182.4600            181.25       down  181.85  ...   \n",
       "...      ...                ...               ...        ...     ...  ...   \n",
       "9159       0           258.5150            266.86         up  256.00  ...   \n",
       "9160       0             3.1599              0.00  no_change    0.50  ...   \n",
       "9161       0           263.5095              0.00  no_change  261.00  ...   \n",
       "9162       2             2.9770              2.56       down    0.25  ...   \n",
       "9163       0           268.5041              0.00  no_change  266.00  ...   \n",
       "\n",
       "      change  change_percent  implied_volatility   delta   gamma   theta  \\\n",
       "0     -1.495         -0.0078              0.0000  1.0000  0.0000  0.0000   \n",
       "1      0.005          1.0000              0.0000  0.0000  0.0000  0.0000   \n",
       "2     -0.615         -0.0033              0.0000  1.0000  0.0000  0.0000   \n",
       "3      0.000          0.0000              0.0000  0.0000  0.0000  0.0000   \n",
       "4     -1.605         -0.0088              0.0000  1.0000  0.0000  0.0000   \n",
       "...      ...             ...                 ...     ...     ...     ...   \n",
       "9159   0.000          0.0000              0.0000 -0.9998  0.0000 -0.0153   \n",
       "9160   0.000          0.0000              0.1207  0.0760  0.0014 -0.0074   \n",
       "9161   0.000          0.0000              0.0000 -0.9998  0.0000 -0.0149   \n",
       "9162   2.560          0.0000              0.1200  0.0722  0.0013 -0.0072   \n",
       "9163   0.000          0.0000              0.0000 -0.9998  0.0000 -0.0146   \n",
       "\n",
       "        vega     rho  last_trade_timestamp  dte  \n",
       "0     0.0000 -0.0001   2024-06-14 14:16:52   -1  \n",
       "1     0.0000  0.0000   2024-06-14 09:32:54   -1  \n",
       "2     0.0000 -0.0001   2024-06-14 15:57:53   -1  \n",
       "3     0.0000  0.0000   2024-06-05 13:19:59   -1  \n",
       "4     0.0000 -0.0001   2024-06-14 14:17:16   -1  \n",
       "...      ...     ...                   ...  ...  \n",
       "9159  0.0000 -0.1534   2024-06-11 09:41:34  916  \n",
       "9160  1.2912  0.9325                   NaT  916  \n",
       "9161  0.0000 -0.1546                   NaT  916  \n",
       "9162  1.2440  0.8859   2024-06-14 12:22:40  916  \n",
       "9163  0.0000 -0.1554                   NaT  916  \n",
       "\n",
       "[9164 rows x 27 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(chains)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5d5295b0",
   "metadata": {},
   "source": [
    "Sets a MultiIndex on the 'chains' DataFrame using the columns 'expiration', 'strike', and 'option_type' and displays it"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "97f67987",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = chains.set_index([\"expiration\", \"strike\", \"option_type\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "c0944292",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>contract_symbol</th>\n",
       "      <th>open_interest</th>\n",
       "      <th>volume</th>\n",
       "      <th>theoretical_price</th>\n",
       "      <th>last_trade_price</th>\n",
       "      <th>tick</th>\n",
       "      <th>bid</th>\n",
       "      <th>bid_size</th>\n",
       "      <th>ask</th>\n",
       "      <th>ask_size</th>\n",
       "      <th>...</th>\n",
       "      <th>change</th>\n",
       "      <th>change_percent</th>\n",
       "      <th>implied_volatility</th>\n",
       "      <th>delta</th>\n",
       "      <th>gamma</th>\n",
       "      <th>theta</th>\n",
       "      <th>vega</th>\n",
       "      <th>rho</th>\n",
       "      <th>last_trade_timestamp</th>\n",
       "      <th>dte</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>expiration</th>\n",
       "      <th>strike</th>\n",
       "      <th>option_type</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2024-06-14</th>\n",
       "      <th rowspan=\"2\" valign=\"top\">350.0</th>\n",
       "      <th>call</th>\n",
       "      <td>SPY240614C00350000</td>\n",
       "      <td>149</td>\n",
       "      <td>147</td>\n",
       "      <td>192.4600</td>\n",
       "      <td>191.34</td>\n",
       "      <td>down</td>\n",
       "      <td>191.83</td>\n",
       "      <td>60</td>\n",
       "      <td>193.06</td>\n",
       "      <td>50</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.495</td>\n",
       "      <td>-0.0078</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>2024-06-14 14:16:52</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>put</th>\n",
       "      <td>SPY240614P00350000</td>\n",
       "      <td>1061</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.01</td>\n",
       "      <td>no_change</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0</td>\n",
       "      <td>0.01</td>\n",
       "      <td>2814</td>\n",
       "      <td>...</td>\n",
       "      <td>0.005</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>2024-06-14 09:32:54</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">355.0</th>\n",
       "      <th>call</th>\n",
       "      <td>SPY240614C00355000</td>\n",
       "      <td>0</td>\n",
       "      <td>64</td>\n",
       "      <td>187.4600</td>\n",
       "      <td>187.24</td>\n",
       "      <td>down</td>\n",
       "      <td>186.85</td>\n",
       "      <td>250</td>\n",
       "      <td>188.06</td>\n",
       "      <td>50</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.615</td>\n",
       "      <td>-0.0033</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>2024-06-14 15:57:53</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>put</th>\n",
       "      <td>SPY240614P00355000</td>\n",
       "      <td>466</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.01</td>\n",
       "      <td>down</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0</td>\n",
       "      <td>0.01</td>\n",
       "      <td>2770</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>2024-06-05 13:19:59</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>360.0</th>\n",
       "      <th>call</th>\n",
       "      <td>SPY240614C00360000</td>\n",
       "      <td>32</td>\n",
       "      <td>6</td>\n",
       "      <td>182.4600</td>\n",
       "      <td>181.25</td>\n",
       "      <td>down</td>\n",
       "      <td>181.85</td>\n",
       "      <td>250</td>\n",
       "      <td>183.06</td>\n",
       "      <td>50</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.605</td>\n",
       "      <td>-0.0088</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>1.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0001</td>\n",
       "      <td>2024-06-14 14:17:16</td>\n",
       "      <td>-1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <th>...</th>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">2026-12-18</th>\n",
       "      <th>800.0</th>\n",
       "      <th>put</th>\n",
       "      <td>SPY261218P00800000</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>258.5150</td>\n",
       "      <td>266.86</td>\n",
       "      <td>up</td>\n",
       "      <td>256.00</td>\n",
       "      <td>45</td>\n",
       "      <td>260.89</td>\n",
       "      <td>50</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.9998</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0153</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1534</td>\n",
       "      <td>2024-06-11 09:41:34</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">805.0</th>\n",
       "      <th>call</th>\n",
       "      <td>SPY261218C00805000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3.1599</td>\n",
       "      <td>0.00</td>\n",
       "      <td>no_change</td>\n",
       "      <td>0.50</td>\n",
       "      <td>46</td>\n",
       "      <td>5.32</td>\n",
       "      <td>75</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.1207</td>\n",
       "      <td>0.0760</td>\n",
       "      <td>0.0014</td>\n",
       "      <td>-0.0074</td>\n",
       "      <td>1.2912</td>\n",
       "      <td>0.9325</td>\n",
       "      <td>NaT</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>put</th>\n",
       "      <td>SPY261218P00805000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>263.5095</td>\n",
       "      <td>0.00</td>\n",
       "      <td>no_change</td>\n",
       "      <td>261.00</td>\n",
       "      <td>45</td>\n",
       "      <td>265.88</td>\n",
       "      <td>50</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.9998</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0149</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1546</td>\n",
       "      <td>NaT</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">810.0</th>\n",
       "      <th>call</th>\n",
       "      <td>SPY261218C00810000</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2.9770</td>\n",
       "      <td>2.56</td>\n",
       "      <td>down</td>\n",
       "      <td>0.25</td>\n",
       "      <td>52</td>\n",
       "      <td>5.00</td>\n",
       "      <td>20</td>\n",
       "      <td>...</td>\n",
       "      <td>2.560</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.1200</td>\n",
       "      <td>0.0722</td>\n",
       "      <td>0.0013</td>\n",
       "      <td>-0.0072</td>\n",
       "      <td>1.2440</td>\n",
       "      <td>0.8859</td>\n",
       "      <td>2024-06-14 12:22:40</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>put</th>\n",
       "      <td>SPY261218P00810000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>268.5041</td>\n",
       "      <td>0.00</td>\n",
       "      <td>no_change</td>\n",
       "      <td>266.00</td>\n",
       "      <td>45</td>\n",
       "      <td>270.88</td>\n",
       "      <td>50</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.9998</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.0146</td>\n",
       "      <td>0.0000</td>\n",
       "      <td>-0.1554</td>\n",
       "      <td>NaT</td>\n",
       "      <td>916</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9164 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  contract_symbol  open_interest  volume  \\\n",
       "expiration strike option_type                                              \n",
       "2024-06-14 350.0  call         SPY240614C00350000            149     147   \n",
       "                  put          SPY240614P00350000           1061       1   \n",
       "           355.0  call         SPY240614C00355000              0      64   \n",
       "                  put          SPY240614P00355000            466       0   \n",
       "           360.0  call         SPY240614C00360000             32       6   \n",
       "...                                           ...            ...     ...   \n",
       "2026-12-18 800.0  put          SPY261218P00800000              1       0   \n",
       "           805.0  call         SPY261218C00805000              0       0   \n",
       "                  put          SPY261218P00805000              0       0   \n",
       "           810.0  call         SPY261218C00810000              0       2   \n",
       "                  put          SPY261218P00810000              0       0   \n",
       "\n",
       "                               theoretical_price  last_trade_price       tick  \\\n",
       "expiration strike option_type                                                   \n",
       "2024-06-14 350.0  call                  192.4600            191.34       down   \n",
       "                  put                     0.0000              0.01  no_change   \n",
       "           355.0  call                  187.4600            187.24       down   \n",
       "                  put                     0.0000              0.01       down   \n",
       "           360.0  call                  182.4600            181.25       down   \n",
       "...                                          ...               ...        ...   \n",
       "2026-12-18 800.0  put                   258.5150            266.86         up   \n",
       "           805.0  call                    3.1599              0.00  no_change   \n",
       "                  put                   263.5095              0.00  no_change   \n",
       "           810.0  call                    2.9770              2.56       down   \n",
       "                  put                   268.5041              0.00  no_change   \n",
       "\n",
       "                                  bid  bid_size     ask  ask_size  ...  \\\n",
       "expiration strike option_type                                      ...   \n",
       "2024-06-14 350.0  call         191.83        60  193.06        50  ...   \n",
       "                  put            0.00         0    0.01      2814  ...   \n",
       "           355.0  call         186.85       250  188.06        50  ...   \n",
       "                  put            0.00         0    0.01      2770  ...   \n",
       "           360.0  call         181.85       250  183.06        50  ...   \n",
       "...                               ...       ...     ...       ...  ...   \n",
       "2026-12-18 800.0  put          256.00        45  260.89        50  ...   \n",
       "           805.0  call           0.50        46    5.32        75  ...   \n",
       "                  put          261.00        45  265.88        50  ...   \n",
       "           810.0  call           0.25        52    5.00        20  ...   \n",
       "                  put          266.00        45  270.88        50  ...   \n",
       "\n",
       "                               change  change_percent  implied_volatility  \\\n",
       "expiration strike option_type                                               \n",
       "2024-06-14 350.0  call         -1.495         -0.0078              0.0000   \n",
       "                  put           0.005          1.0000              0.0000   \n",
       "           355.0  call         -0.615         -0.0033              0.0000   \n",
       "                  put           0.000          0.0000              0.0000   \n",
       "           360.0  call         -1.605         -0.0088              0.0000   \n",
       "...                               ...             ...                 ...   \n",
       "2026-12-18 800.0  put           0.000          0.0000              0.0000   \n",
       "           805.0  call          0.000          0.0000              0.1207   \n",
       "                  put           0.000          0.0000              0.0000   \n",
       "           810.0  call          2.560          0.0000              0.1200   \n",
       "                  put           0.000          0.0000              0.0000   \n",
       "\n",
       "                                delta   gamma   theta    vega     rho  \\\n",
       "expiration strike option_type                                           \n",
       "2024-06-14 350.0  call         1.0000  0.0000  0.0000  0.0000 -0.0001   \n",
       "                  put          0.0000  0.0000  0.0000  0.0000  0.0000   \n",
       "           355.0  call         1.0000  0.0000  0.0000  0.0000 -0.0001   \n",
       "                  put          0.0000  0.0000  0.0000  0.0000  0.0000   \n",
       "           360.0  call         1.0000  0.0000  0.0000  0.0000 -0.0001   \n",
       "...                               ...     ...     ...     ...     ...   \n",
       "2026-12-18 800.0  put         -0.9998  0.0000 -0.0153  0.0000 -0.1534   \n",
       "           805.0  call         0.0760  0.0014 -0.0074  1.2912  0.9325   \n",
       "                  put         -0.9998  0.0000 -0.0149  0.0000 -0.1546   \n",
       "           810.0  call         0.0722  0.0013 -0.0072  1.2440  0.8859   \n",
       "                  put         -0.9998  0.0000 -0.0146  0.0000 -0.1554   \n",
       "\n",
       "                               last_trade_timestamp  dte  \n",
       "expiration strike option_type                             \n",
       "2024-06-14 350.0  call          2024-06-14 14:16:52   -1  \n",
       "                  put           2024-06-14 09:32:54   -1  \n",
       "           355.0  call          2024-06-14 15:57:53   -1  \n",
       "                  put           2024-06-05 13:19:59   -1  \n",
       "           360.0  call          2024-06-14 14:17:16   -1  \n",
       "...                                             ...  ...  \n",
       "2026-12-18 800.0  put           2024-06-11 09:41:34  916  \n",
       "           805.0  call                          NaT  916  \n",
       "                  put                           NaT  916  \n",
       "           810.0  call          2024-06-14 12:22:40  916  \n",
       "                  put                           NaT  916  \n",
       "\n",
       "[9164 rows x 24 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "display(df)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b70141dc",
   "metadata": {},
   "source": [
    "**Jason Strimpel** is the founder of <a href='https://pyquantnews.com/'>PyQuant News</a> and co-founder of <a href='https://www.tradeblotter.io/'>Trade Blotter</a>. His career in algorithmic trading spans 20+ years. He previously traded for a Chicago-based hedge fund, was a risk manager at JPMorgan, and managed production risk technology for an energy derivatives trading firm in London. In Singapore, he served as APAC CIO for an agricultural trading firm and built the data science team for a global metals trading firm. Jason holds degrees in Finance and Economics and a Master's in Quantitative Finance from the Illinois Institute of Technology. His career spans America, Europe, and Asia. He shares his expertise through the <a href='https://pyquantnews.com/subscribe-to-the-pyquant-newsletter/'>PyQuant Newsletter</a>, social media, and has taught over 1,000+ algorithmic trading with Python in his popular course **<a href='https://gettingstartedwithpythonforquantfinance.com/'>Getting Started With Python for Quant Finance</a>**. All code is for educational purposes only. Nothing provided here is financial advise. Use at your own risk."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d29d0c0-34d5-4363-bd70-2df08cd7ed8c",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "main_language": "python",
   "notebook_metadata_filter": "-all"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
